package com.zj.study.strategy;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author 赵赳
 * @since 2022/7/21 13:51
 */
//@Component
public class DefaultUnitePayment01 implements UnitePayment {

  private static final Map<String, PaymentStrategy> STRATEGY_MAP = new ConcurrentHashMap<>();

  static {
    STRATEGY_MAP.put("1", new AliPaymentService());
    STRATEGY_MAP.put("2", new WeChatPaymentService());
  }

  public static PaymentStrategy getPaymentStrategy(String code) {
    return STRATEGY_MAP.get(code);
  }


  @Override
  public PaymentStrategy payStrategy(Integer type) {
    switch (type) {
      case 1:
        return new AliPaymentService();
      case 2:
        return new WeChatPaymentService();
    }
    return null;
  }


}
